var path = require('path');

var htmlWebpackPlugin = require('html-webpack-plugin')
var VueLoaderPlugin = require('vue-loader/lib/plugin');
// module.exports = {
//     entry:path.join(__dirname,'./src/index.js'),
//     output:{
//         path:path.join(__dirname,'./dist'),
//         filename:'bundle.js'
//     },
//     plugins:[   //所有webpack 插件的配置节点
//         new htmlWebpackPlugin({
//             template:path.join(__dirname,'./src/index.html'),   //指定模板文件路径
//             filename:'index.html'
//         })
//     ],
// }

module.exports = {
    mode:'development',
    entry: './src/index.js',
    output: {
      path: __dirname + '/dist',
      filename: 'index_bundle.js'
    },
    plugins: [
      new htmlWebpackPlugin({
          template:path.join(__dirname,'./src/index.html'),
          filename:'index.html'
      }),
      new VueLoaderPlugin()
    ],
    module:{
        rules:[
            { test: /\.css$/,  use: ["style-loader","css-loader"] },
            { test: /\.scss$/,  use: ["style-loader","css-loader","sass-loader"] },

            {test:/\.(jpg|png|gif|bmp|jpeg)$/,use:'url-loader?limit=300000&name=-[hash][name].[ext]'},

            { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" },

            {test:/\.(ttf|eot|svg|woff|woff2)$/,use:'url-loader'},

            { test:/\.vue$/,use:'vue-loader'}
        ]
    },
    resolve: {
      // alias: {
      //   'vue$': 'vue/dist/vue.esm.js' // 用 webpack 1 时需用 'vue/dist/vue.common.js'
      // }
    }
  }